// JavaScript Document
function list_select_all() {
	var all = document.getElementById("all");
	var ids = document.getElementsByName("id");
	if (ids == null) {
		return;
	}
	for ( var i = 0; i < ids.length; i++) {
		ids[i].checked = all.checked;
	}
	list_check_selection();
}

function list_checked_count() {
	var ids = document.getElementsByName("id");
	var idchecked = 0;
	if (ids != null) {
		for ( var i = 0; i < ids.length; i++) {
			if (ids[i].checked) {
				idchecked++;
			}
		}
	}
	return idchecked;
}

function list_check_selection() {
	var all = document.getElementById("all");
	var ids = document.getElementsByName("id");
	if (ids == null || ids.length == 0) {
		if (all == null) {
			return;
		}
		var f = all.form;
		for ( var i = 0; i < f.elements.length; i++) {
			if (f.elements[i].type == "button"
					|| f.elements[i].type == "submit") {
				var ss = f.elements[i].getAttribute("selectionmode");
				if (ss == "one" || ss == "more") {
					f.elements[i].disabled = true;
				} else {
					f.elements[i].disabled = false;
				}
			}
		}
	} else {
		var f = ids[0].form;
		var idchecked = list_checked_count();

		if (all != null) {
			if (idchecked == 0) {
				all.checked = false;
			}
			if (idchecked == ids.length) {
				all.checked = true;
			}
		}
		if (idchecked == 0) {
			for ( var i = 0; i < f.elements.length; i++) {
				if (f.elements[i].type == "button"
						|| f.elements[i].type == "submit") {
					var ss = f.elements[i].getAttribute("selectionmode");
					if (ss == "one" || ss == "more") {
						f.elements[i].disabled = true;
					} else {
						f.elements[i].disabled = false;
					}
				}
			}
		} else if (idchecked > 1) {
			for ( var i = 0; i < f.elements.length; i++) {
				if (f.elements[i].type == "button"
						|| f.elements[i].type == "submit") {
					var ss = f.elements[i].getAttribute("selectionmode");
					if (ss == "one") {
						f.elements[i].disabled = true;
					} else {
						f.elements[i].disabled = false;
					}
				}
			}
		} else {
			for ( var i = 0; i < f.elements.length; i++) {
				if (f.elements[i].type == "button"
						|| f.elements[i].type == "submit") {
					f.elements[i].disabled = false;
				}
			}
		}
	}
}